package Dashboard;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

/**
 * This is a JPanel modified to easily display an image
 * 
 * @author Sietse
 *
 */
public class ImagePanel extends JPanel
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3617842772922409182L;

	//The image for the panel
	private BufferedImage image;
	
	//The offsets
	private int x, y;
	
	/**
	 * Paint the images with no offsets
	 * @param image
	 */
	public ImagePanel(BufferedImage image)
	{
		this.setDoubleBuffered(true);
		this.setOpaque(true);
		
		x = 0;
		y = 0;
		this.image = image;

		this.setOpaque(true);
	}
	
	/**
	 * Paint the image with the specified offsets
	 * @param image
	 * @param x
	 * @param y
	 */
	public ImagePanel(BufferedImage image, int x, int y)
	{
		this.setDoubleBuffered(true);
		this.setOpaque(true);
		this.x = x;
		this.y = y;
		this.image = image;

	}
	
	/**
	 * A custom (manual) paint method
	 * @param g the Grahpics it needs to paint on
	 */
	public void paintM(Graphics g)
	{
		g.drawImage(image, this.x, this.y, null);
	}
	
	/**
	 * A custom (manual) paint method with offsets
	 * @param g the Graphics it needs to paint on
	 * @param x
	 * @param y
	 */
	public void paintM(Graphics g, int x, int y)
	{
		g.drawImage(image, x, y, null);
	}
}
